package br.com.globalcode.clinicafacil.modelo.entidade;

public class Paciente implements Comparable {

	private int id;
	private String nome;
	private String cpf;

	public Paciente() {
	}
	
	public Paciente(String nome, String cpf) {
		this.nome = nome;
		this.cpf = cpf;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public String getCpf() {
		return cpf;
	}

	public void setCpf(String cpf) {
		this.cpf = cpf;
	}
	
	
	
	/*@Override
	public int hashCode() {
		final int PRIME = 31;

		int hash = PRIME * nome.hashCode();
		hash += PRIME * cpf.hashCode();
		
		return hash;
	}

	@Override
	public boolean equals(Object obj) {
		
		if (  this == obj  ) return true;
		
		if ( obj == null ) return false;
		
		if ( ! (obj instanceof Paciente) ) return false;
		
		Paciente outro = (Paciente) obj;
		
		if (!this.nome.equals(outro.getNome())) return false;
		
		if (!this.cpf.equals(outro.getCpf())) return false;
		
		return true;
	}*/

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((cpf == null) ? 0 : cpf.hashCode());
		result = prime * result + ((nome == null) ? 0 : nome.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Paciente other = (Paciente) obj;
		if (cpf == null) {
			if (other.cpf != null)
				return false;
		} else if (!cpf.equals(other.cpf))
			return false;
		
		if (nome == null) {
			if (other.nome != null)
				return false;
		} else if (!nome.equals(other.nome))
			return false;
		return true;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("Paciente [id=")
			   .append(id)
			   .append(", nome=")
			   .append(nome)
			   .append(", cpf=")
			   .append(cpf)
			   .append("]");
		return builder.toString();
	}

	@Override
	public int compareTo(Object o) {
		
		if (getClass() != o.getClass() ) return -1;
		
		Paciente outroPaciente = (Paciente) o;
		
		return nome.compareTo(outroPaciente.getNome());	
	}


	

	
	
}
